﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;

namespace WcfClientGenerator.UI.Util
{
    public class TileBackground
    {
        #region Class Fields (Private)

        private static Color[] colors = null;

        #endregion

        #region Constructors

        static TileBackground()
        {
            Color orange = Color.FromRgb(0xFF, 0xA5, 0x00);
            Color brown = Color.FromRgb(0xA5, 0x2A, 0x2A);
            Color pink = Color.FromRgb(0xFF, 0xC0, 0xCB);
            Color lime = Color.FromRgb(0x00, 0xFF, 0x00);
            Color blue = Color.FromRgb(0x00, 0x00, 0xFF);
            Color red = Color.FromRgb(0xFF, 0x00, 0x00);
            Color green = Color.FromRgb(0x00, 0x80, 0x00);

            TileBackground.colors = new Color[] {
                orange, brown, pink, lime, blue, red, green
            };
        }

        #endregion

        #region Properties (Public)

        public static Color Default
        {
            get
            {
                return TileBackground.colors[TileBackground.DefaultColorIndex];
            }
        }

        public static int DefaultColorIndex
        {
            get
            {
                return 0;
            }
        }

        public static int Count
        {
            get
            {
                return TileBackground.colors.Length;
            }
        }

        #endregion

        #region Methods (Public)

        public static IEnumerable<Color> AsEnumerable()
        {
            return TileBackground.colors;
        }

        public static Color GetColor(int index)
        {
            if (index >= 0 && index < TileBackground.colors.Length)
                return TileBackground.colors[index];
            else
                throw new IndexOutOfRangeException();
        }

        public static IEnumerable<Brush> Brushes
        {
            get
            {
                return TileBackground.colors.
                    Select(c => new SolidColorBrush(c));
            }
        }

        #endregion
    }
}
